package com.jy.adscm.operation.purchase.service.impl;


import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.jy.adscm.operation.purchase.bean.BasePurchase;
import com.jy.adscm.operation.purchase.mapper.mysql.BasePurchaseMapper;
import com.jy.adscm.operation.purchase.service.BasePurchaseService;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author lzf
 * @since 2019-04-22
 */
@Service
public class BasePurchaseServiceImpl extends ServiceImpl<BasePurchaseMapper, BasePurchase> implements BasePurchaseService {
@Autowired
private BasePurchaseMapper basePurchaseMapper;

    @Override
    public Integer save(BasePurchase basePurchase) {
        basePurchase.setRecodeCreateTime(new Date());
        basePurchase.setDepartment(basePurchaseMapper.queryIdByDept(basePurchase.getApplyPerson()).getId());

        return basePurchaseMapper.insert(basePurchase);
    }

    @Override
    public List<BasePurchase> queryByStatus(int applyPerson) {
        Wrapper<BasePurchase> basePurchaseWrapper=new EntityWrapper<>();
        basePurchaseWrapper.eq("applyPerson",applyPerson);
        List<BasePurchase> basePurchaseList = basePurchaseMapper.selectList(basePurchaseWrapper);
        return basePurchaseList;
    }
}
